package net.binarymuse.embjettest.servlets;

import java.io.IOException;
import java.util.Enumeration;
import java.util.Random;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import net.binarymuse.embjettest.State;

public class SessionServlet extends HttpServlet {

    private static final long serialVersionUID = -5896453056121248656L;
    
    private State state;
    
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    {
        response.setContentType("text/html");
        response.setStatus(HttpServletResponse.SC_OK);
        response.getWriter().println("<html><head><title>Embedded Jetty Test</title></head><body>");
        response.getWriter().println("Servlet processing<br />");
        response.getWriter().println("session=" + request.getSession(true).getId() + "<br />");
        response.getWriter().println(request.toString() + "<br />");
        
        // Generate values for our two state objects
        Random random = new Random();
        int num = random.nextInt(1000000);
        String sNum = Integer.toString(num);
        int num2 = random.nextInt(1000000);
        String sNum2 = Integer.toString(num2);
        
        response.getWriter().println("<h1>" + request.getParameterValues("name")[0]+"</h1> hello");
        
        
        response.getWriter().println("</body></html>");
    }

}
